home *** CD-ROM | disk | FTP | other *** search
/ Gamers Delight 2 / Gamers Delight 2.iso / Aminet / game / role / AMScen_0_9.lha / AMScen / proving5.m < prev    next >
Text File  |  1995-01-21  |  23KB  |  707 lines

  1. /*
  2.  * Amiga MUD
  3.  *
  4.  * Copyright (c) 1995 by Chris Gray
  5.  */
  6.  
  7. /*
  8.  * proving5.m - the doors rooms area.
  9.  */
  10.  
  11. private tp_proving5 CreateTable().
  12. use tp_proving5
  13.  
  14. define tp_proving5 r_tunnelX4 CreateThing(r_provingCave).
  15. SetupRoomDP(r_tunnelX4, "at the south end of a passage",
  16.     "A large wooden door blocks the south end of the passage.").
  17. UniConnect(r_tunnelX4, r_chasm6, D_SOUTH).
  18. r_tunnelX4@p_rNoGenerateMonsters := true.
  19. define tp_proving5 PR_TUNNELX4_ID NextEffectId().
  20. define tp_proving5 proc drawTunnelX4()void:
  21.  
  22.     if not KnowsEffect(nil, PR_TUNNELX4_ID) then
  23.     DefineEffect(nil, PR_TUNNELX4_ID);
  24.     GSetImage(nil, "pr_tunnelX4");
  25.     IfFound(nil);
  26.         GShowImage(nil, "", 0, 0, 160, 100, 0, 0);
  27.     Else(nil);
  28.         GSetPen(nil, C_DARK_GREY);
  29.         GAMove(nil, 0, 0);
  30.         GRectangle(nil, 159, 99, true);
  31.         GSetPen(nil, C_LIGHT_GREY);
  32.         GAMove(nil, 65, 0);
  33.         GRectangle(nil, 29, 55, true);
  34.         GSetPen(nil, C_BROWN);
  35.         GAMove(nil, 75, 55);
  36.         HorizontalDoor();
  37.     Fi(nil);
  38.     EndEffect();
  39.     fi;
  40.     CallEffect(nil, PR_TUNNELX4_ID);
  41. corp;
  42. AutoGraphics(r_tunnelX4, drawTunnelX4).
  43.  
  44. define tp_proving5 o_door1 CreateThing(nil).
  45. FakeObject(o_door1, r_chasm6, "door;sturdy,wooden",
  46.     "The door is made from massive wooden beams, fastened together with thick "
  47.     "iron straps. There is a small round keyhole in the door.").
  48. o_door1@p_oOpenString := "The door is locked.".
  49. o_door1@p_oPushString := "The door is locked.".
  50. o_door1@p_oPullString := "The door is locked.".
  51.  
  52. define tp_proving5 o_keyHole2 CreateThing(nil).
  53. FakeObject(o_keyHole2, r_chasm6, "hole,keyhole;small,round", "").
  54. o_keyHole2@p_oContents := CreateThingList().
  55.  
  56. define tp_proving5 proc putInKeyHole2(thing key, keyhole)status:
  57.     string name;
  58.     bool hidden;
  59.  
  60.     if Parent(key) = o_ironKey then
  61.     name := Me()@p_pName;
  62.     hidden := Me()@p_pHidden;
  63.     Print("The iron key slips into the hole and turns easily. The door "
  64.         "opens and you walk through.\n");
  65.     if hidden then
  66.         OPrint("The door opens, then quickly closes again.\n");
  67.     else
  68.         OPrint(name + " unlocks the door and walks through. The door "
  69.         "then closes again before anyone can follow.\n");
  70.     fi;
  71.     LeaveRoomStuff(r_tunnelX4, D_NORTH, MOVE_SPECIAL);
  72.     EnterRoomStuff(r_tunnelX4, D_SOUTH, MOVE_SPECIAL);
  73.     if hidden then
  74.         OPrint("The door opens, then closes again.\n");
  75.     else
  76.         OPrint("The door opens and " + name + " enters. " +
  77.         "The door quickly closes again.\n");
  78.     fi;
  79.     succeed
  80.     else
  81.     Print("The " + FormatName(key@p_oName) +
  82.         " will not fit into the hole.\n");
  83.     fail
  84.     fi
  85. corp;
  86. o_keyHole2@p_oPutInMeChecker := putInKeyHole2.
  87. define tp_proving5 proc doUnlock2(thing keyhole, key)status:
  88.     putInKeyHole2(key, keyhole)
  89. corp;
  90. o_keyHole2@p_oUnlockMeWithChecker := doUnlock2.
  91. SetThingStatus(o_keyHole2, ts_readonly).
  92. o_door1@p_oUnlockMeWithChecker := doUnlock2.
  93. SetThingStatus(o_door1, ts_readonly).
  94.  
  95. define tp_proving5 proc backThroughDoor()status:
  96.     string name;
  97.     bool hidden;
  98.  
  99.     name := Me()@p_pName;
  100.     hidden := Me()@p_pHidden;
  101.     Print("The door opens easily from this side. You pass back into the "
  102.     "chasm area and the door closes and locks again.\n");
  103.     if hidden then
  104.     OPrint("The door opens, then quickly closes again.\n");
  105.     else
  106.     OPrint(name + " opens the door and passes through. The door quickly "
  107.         "closes again.\n");
  108.     fi;
  109.     LeaveRoomStuff(r_chasm6, D_SOUTH, MOVE_SPECIAL);
  110.     EnterRoomStuff(r_chasm6, D_NORTH, MOVE_SPECIAL);
  111.     if hidden then
  112.     OPrint("The door opens, then quickly closes again.\n");
  113.     else
  114.     OPrint("The door opens and " + name + " emerges. "
  115.         "The door quickly closes again.\n");
  116.     fi;
  117.     succeed
  118. corp;
  119. define tp_proving5 proc doBackThroughDoor()status:
  120.     ignore backThroughDoor();
  121.     fail
  122. corp;
  123. AddSouthChecker(r_tunnelX4, doBackThroughDoor, false).
  124.  
  125. define tp_proving5 o_door2 CreateThing(nil).
  126. FakeObject(o_door2, r_tunnelX4, "door;sturdy,wooden", "").
  127. o_door2@p_oOpenChecker := backThroughDoor.
  128. o_door2@p_oPullChecker := backThroughDoor.
  129. o_door2@p_oPushChecker := backThroughDoor.
  130. o_door2@p_oNotLocked := true.
  131.  
  132. /* Here for a while is the area beyond the door in the crack in the chasm.
  133.    This is the doorsroom area with the winch. */
  134.  
  135. define tp_proving5 r_tunnelX CreateThing(r_tunnel).
  136. r_tunnelX@p_rDark := true.
  137. AutoGraphics(r_tunnelX, AutoTunnels).
  138. AutoPens(r_tunnelX, C_DARK_GREY, C_LIGHT_GREY, C_LIGHT_GREY, C_LIGHT_GREY).
  139. SetThingStatus(r_tunnelX, ts_readonly).
  140.  
  141. define tp_proving5 r_tunnelX5 CreateThing(r_tunnelX).
  142. SetupRoomDP(r_tunnelX5, "in a north-south passage",
  143.     "There is a winch arrangement on the wall here.").
  144. Connect(r_tunnelX4, r_tunnelX5, D_NORTH).
  145. Scenery(r_tunnelX5, "hole.rope").
  146. r_tunnelX5@p_rHintString := "Why do they close so suddenly?".
  147.  
  148. define tp_proving5 r_tunnelX6 CreateThing(r_tunnelX).
  149. SetupRoomDP(r_tunnelX6, "in a north-south passage", "").
  150. Connect(r_tunnelX5, r_tunnelX6, D_NORTH).
  151.  
  152. define tp_proving5 r_tunnelX7 CreateThing(r_tunnelX).
  153. SetupRoomDP(r_tunnelX7, "in a north-south passage", "").
  154. Connect(r_tunnelX6, r_tunnelX7, D_NORTH).
  155.  
  156. define tp_proving5 PR_DOORS1_ID NextEffectId().
  157. define tp_proving5 proc drawDoors1()void:
  158.  
  159.     if not KnowsEffect(nil, PR_DOORS1_ID) then
  160.     DefineEffect(nil, PR_DOORS1_ID);
  161.     GSetPen(nil, C_BROWN);
  162.     GAMove(nil, 40, 66);
  163.     VerticalDoor();
  164.     GAMove(nil, 52, 48);
  165.     NorthWestDoor();
  166.     GAMove(nil, 76, 40);
  167.     HorizontalDoor();
  168.     GAMove(nil, 108, 48);
  169.     NorthEastDoor();
  170.     GAMove(nil, 120, 66);
  171.     VerticalDoor();
  172.     EndEffect();
  173.     fi;
  174.     CallEffect(nil, PR_DOORS1_ID);
  175. corp;
  176.  
  177. define tp_proving5 PR_DOORS2_ID NextEffectId().
  178. define tp_proving5 proc drawDoors2()void:
  179.  
  180.     if not KnowsEffect(nil, PR_DOORS2_ID) then
  181.     DefineEffect(nil, PR_DOORS2_ID);
  182.     GSetImage(nil, "pr_doors2");
  183.     IfFound(nil);
  184.         GShowImage(nil, "", 0, 0, 160, 100, 0, 0);
  185.     Else(nil);
  186.         GSetPen(nil, C_DARK_GREY);
  187.         GAMove(nil, 0, 0);
  188.         GRectangle(nil, 159, 99, true);
  189.  
  190.         GSetPen(nil, C_LIGHT_GREY);
  191.         GPolygonStart(nil);
  192.         GAMove(nil, 70, 99);
  193.         GRDraw(nil, -10, -19);
  194.         GRDraw(nil, -20, 0);
  195.         GRDraw(nil, 0, -20);
  196.         GRDraw(nil, 20, -20);
  197.         GRDraw(nil, 40, 0);
  198.         GRDraw(nil, 20, 20);
  199.         GRDraw(nil, 0, 20);
  200.         GRDraw(nil, -20, 0);
  201.         GRDraw(nil, -10, 19);
  202.         GPolygonEnd(nil);
  203.  
  204.         drawDoors1();
  205.     Fi(nil);
  206.     EndEffect();
  207.     fi;
  208.     CallEffect(nil, PR_DOORS2_ID);
  209. corp;
  210.  
  211. define tp_proving5 PR_DOORS3_ID NextEffectId().
  212. define tp_proving5 proc drawDoors3()void:
  213.  
  214.     if not KnowsEffect(nil, PR_DOORS3_ID) then
  215.     DefineEffect(nil, PR_DOORS3_ID);
  216.     GSetImage(nil, "pr_doors3");
  217.     IfFound(nil);
  218.         GShowImage(nil, "", 0, 0, 160, 100, 0, 0);
  219.     Else(nil);
  220.         GSetPen(nil, C_DARK_GREY);
  221.         GAMove(nil, 0, 0);
  222.         GRectangle(nil, 159, 99, true);
  223.  
  224.         GSetPen(nil, C_LIGHT_GREY);
  225.         GPolygonStart(nil);
  226.         GAMove(nil, 70, 99);
  227.         GRDraw(nil, -10, -19);
  228.         GRDraw(nil, -40, 0);
  229.         GRDraw(nil, 0, -60);
  230.         GRDraw(nil, 120, 0);
  231.         GRDraw(nil, 0, 60);
  232.         GRDraw(nil, -40, 0);
  233.         GRDraw(nil, -10, 19);
  234.         GPolygonEnd(nil);
  235.         GAMove(nil, 70, 0);
  236.         GRectangle(nil, 20, 20, true);
  237.  
  238.         GSetPen(nil, C_DARK_GREY);
  239.         GAMove(nil, 40, 80);
  240.         GRDraw(nil, 0, -20);
  241.         GRDraw(nil, 20, -20);
  242.         GRDraw(nil, 40, 0);
  243.         GRDraw(nil, 20, 20);
  244.         GRDraw(nil, 0, 20);
  245.  
  246.         drawDoors1();
  247.     Fi(nil);
  248.     EndEffect();
  249.     fi;
  250.     CallEffect(nil, PR_DOORS3_ID);
  251. corp;
  252.  
  253. define tp_proving5 DOORS1_MAP_GROUP NextMapGroup().
  254. define tp_proving5 DOORS2_MAP_GROUP NextMapGroup().
  255.  
  256. define tp_proving5 r_doorsModel1 CreateThing(r_tunnel).
  257. r_doorsModel1@p_rDark := true.
  258. r_doorsModel1@p_MapGroup := DOORS1_MAP_GROUP.
  259. r_doorsModel1@p_rDrawAction := drawDoors2.
  260. r_doorsModel1@p_rEnterRoomDraw := EnterRoomDraw.
  261. r_doorsModel1@p_rLeaveRoomDraw := LeaveRoomDraw.
  262. RoomName(r_doorsModel1, "Doors", "Room").
  263. Scenery(r_doorsModel1, "eye;carved.carving;eye").
  264. SetThingStatus(r_doorsModel1, ts_readonly).
  265.  
  266. define tp_proving5 proc makeDoors1(int x, y; string name)thing:
  267.     thing doors;
  268.  
  269.     doors := CreateThing(r_doorsModel1);
  270.     doors@p_rName := name;
  271.     doors@p_rContents := CreateThingList();
  272.     doors@p_rExits := CreateIntList();
  273.     doors@p_rCursorX := x;
  274.     doors@p_rCursorY := y;
  275.     SetThingStatus(doors, ts_readonly);
  276.     doors
  277. corp;
  278.  
  279. define tp_proving5 r_doorsModel2 CreateThing(r_tunnel).
  280. r_doorsModel2@p_rDark := true.
  281. r_doorsModel2@p_MapGroup := DOORS2_MAP_GROUP.
  282. r_doorsModel2@p_rDrawAction := drawDoors3.
  283. r_doorsModel2@p_rEnterRoomDraw := EnterRoomDraw.
  284. r_doorsModel2@p_rLeaveRoomDraw := LeaveRoomDraw.
  285. RoomName(r_doorsModel2, "Doors", "Room").
  286. SetThingStatus(r_doorsModel2, ts_readonly).
  287.  
  288. define tp_proving5 proc makeDoors2(int x, y; string name)thing:
  289.     thing doors;
  290.  
  291.     doors := CreateThing(r_doorsModel2);
  292.     doors@p_rName := name;
  293.     doors@p_rContents := CreateThingList();
  294.     doors@p_rExits := CreateIntList();
  295.     doors@p_rCursorX := x;
  296.     doors@p_rCursorY := y;
  297.     SetThingStatus(doors, ts_readonly);
  298.     doors
  299. corp;
  300.  
  301. define tp_proving5 r_doorsEntrance makeDoors1(78, 67,
  302.     "in the room of many doors").
  303. Connect(r_tunnelX7, r_doorsEntrance, D_NORTH).
  304. Scenery(r_doorsEntrance, "door.passage").    /* adds to default */
  305.  
  306. define tp_proving5 r_westDoor makeDoors1(43, 67, "by the west door").
  307. Connect(r_doorsEntrance, r_westDoor, D_WEST).
  308.  
  309. define tp_proving5 r_northwestDoor makeDoors1(52, 51, "by the northwest door").
  310. Connect(r_doorsEntrance, r_northwestDoor, D_NORTHWEST).
  311. Connect(r_westDoor, r_northwestDoor, D_NORTH).
  312.  
  313. define tp_proving5 r_northDoor makeDoors1(78, 42, "by the north door").
  314. Connect(r_doorsEntrance, r_northDoor, D_NORTH).
  315. Connect(r_northwestDoor, r_northDoor, D_EAST).
  316.  
  317. define tp_proving5 r_northeastDoor makeDoors1(102,51, "by the northeast door").
  318. Connect(r_doorsEntrance, r_northeastDoor, D_NORTHEAST).
  319. Connect(r_northDoor, r_northeastDoor, D_EAST).
  320.  
  321. define tp_proving5 r_eastDoor makeDoors1(111, 67, "by the east door").
  322. Connect(r_doorsEntrance, r_eastDoor, D_EAST).
  323. Connect(r_northeastDoor, r_eastDoor, D_SOUTH).
  324.  
  325. define tp_proving5 r_westDoor2 makeDoors2(31, 67, "by the west door").
  326. Connect(r_westDoor, r_westDoor2, D_WEST).
  327.  
  328. define tp_proving5 r_northwestDoor2 makeDoors2(43, 43,"by the northwest door").
  329. Connect(r_northwestDoor, r_northwestDoor2, D_NORTHWEST).
  330. Connect(r_westDoor2, r_northwestDoor2, D_NORTHEAST).
  331. UniConnect(r_westDoor2, r_northwestDoor2, D_NORTH).
  332.  
  333. define tp_proving5 r_northDoor2 makeDoors2(78, 32, "by the north door").
  334. Connect(r_northDoor, r_northDoor2, D_NORTH).
  335. Connect(r_northwestDoor2, r_northDoor2, D_NORTHEAST).
  336. UniConnect(r_northwestDoor2, r_northDoor2, D_NORTH).
  337. UniConnect(r_northDoor2, r_northwestDoor2, D_WEST).
  338.  
  339. define tp_proving5 r_northeastDoor2 makeDoors2(111,43,"by the northeast door").
  340. Connect(r_northeastDoor, r_northeastDoor2, D_NORTHEAST).
  341. Connect(r_northeastDoor2, r_northDoor2, D_NORTHWEST).
  342. UniConnect(r_northeastDoor2, r_northDoor2, D_NORTH).
  343. UniConnect(r_northDoor2, r_northeastDoor2, D_EAST).
  344.  
  345. define tp_proving5 r_eastDoor2 makeDoors2(123, 67, "by the east door").
  346. Connect(r_eastDoor, r_eastDoor2, D_EAST).
  347. Connect(r_eastDoor2, r_northeastDoor2, D_NORTHWEST).
  348. UniConnect(r_eastDoor2, r_northeastDoor2, D_NORTH).
  349.  
  350. define tp_proving r_doorsExit makeDoors2(77, 2,
  351.     "in the room of many doors").
  352. Connect(r_northDoor2, r_doorsExit, D_NORTH).
  353.  
  354. define tp_proving5 o_doorModel1 CreateThing(nil).
  355. FakeObject(o_doorModel1, nil, "door;sturdy,wooden", "").
  356. define tp_proving5 proc door1Desc()string:
  357.     if It()@p_oState = 0 then
  358.     "The door looks like it opens by sliding upwards, but it is currently "
  359.     "closed and you can see no way to open it, nor any sign of a keyhole "
  360.     "or other mechanism."
  361.     else
  362.     /* this cannot ever happen */
  363.     "The door is currently slid upwards out of the way."
  364.     fi
  365. corp;
  366. o_doorModel1@p_oDescAction := door1Desc.
  367. define tp_proving5 proc door1Unlock(thing door, key)status:
  368.     Print("You can see no lock mechanism on the door.\n");
  369.     succeed
  370. corp;
  371. o_doorModel1@p_oUnlockMeWithChecker := door1Unlock.
  372. SetThingStatus(o_doorModel1, ts_readonly).
  373.  
  374. define tp_proving5 o_winch CreateThing(nil).
  375. FakeObject(o_winch, r_tunnelX5, "winch.arrangement;winch.crank", "").
  376. o_winch@p_oState := 0.
  377. define tp_proving5 proc winchDesc()string:
  378.     "The winch is a hand turned mechanism used for lifting things. A rope "
  379.     "transmits the force from the winch through a hole in the ceiling. It is "
  380.     "not obvious what purpose the winch serves. " +
  381.     if o_winch@p_oState = 0 then
  382.     "The winch is currently fully unwound."
  383.     elif o_winch@p_oState = 5 then
  384.     "The winch is currently fully wound."
  385.     else
  386.     "The winch is currently partly wound."
  387.     fi
  388. corp;
  389. o_winch@p_oDescAction := winchDesc.
  390.  
  391. define tp_proving5 p_oOtherDoor CreateThingProp().
  392. define tp_proving5 p_oSound CreateStringProp().
  393. define tp_proving5 p_oDoorName CreateStringProp().
  394. define tp_proving5 p_oSoundList CreateThingListProp().
  395.  
  396. define tp_proving5 o_doorModel2 CreateThing(nil).
  397. FakeObject(o_doorModel2, nil, "door;sturdy,wooden", "").
  398. define tp_proving5 proc door2Desc()string:
  399.     if It()@p_oOtherDoor@p_oState = 0 then
  400.     "The door looks like it opens by sliding upwards. There is a handy "
  401.     "handle on it for lifting with."
  402.     else
  403.     /* Hmm. should never see this! */
  404.     "The door is currently slid upwards out of the way."
  405.     fi
  406. corp;
  407. o_doorModel2@p_oDescAction := door2Desc.
  408. o_doorModel2@p_oNotLocked := true.
  409. SetThingStatus(o_doorModel2, ts_readonly).
  410.  
  411. define tp_proving5 proc door1Checker()status:
  412.  
  413.     if Here()@p_rContents[0]@p_oState = 0 then
  414.     Print("You cannot go that way - the door is closed.\n");
  415.     fail
  416.     else
  417.     continue
  418.     fi
  419. corp;
  420.  
  421. define tp_proving5 proc door2Checker()status:
  422.     thing otherDoor;
  423.  
  424.     otherDoor := Here()@p_rContents[0]@p_oOtherDoor;
  425.     if otherDoor@p_oState = 0 then
  426.     Print("You lift the door by the handle and pass through.\n");
  427.     if CanSee(Here(), Me()) then
  428.         OPrint(Me()@p_pName + " lifts the door and passes through.\n");
  429.     fi;
  430.     SayToList(o_winch@p_oSoundList, otherDoor@p_oSound + "\n");
  431.     /* The enter checker for the other room will shut all the doors if
  432.        the player has a light. */
  433.     fi;
  434.     continue
  435. corp;
  436.  
  437. define tp_proving5 o_door1W CreateThing(o_doorModel1).
  438. o_door1W@p_oState := 0.
  439. o_door1W@p_oSound := "Thump!".
  440. o_door1W@p_oDoorName := "west".
  441. AddTail(r_westDoor@p_rContents, o_door1W).
  442. AddWestChecker(r_westDoor, door1Checker, false).
  443. define tp_proving5 o_door2W CreateThing(o_doorModel2).
  444. o_door2W@p_oOtherDoor := o_door1W.
  445. AddTail(r_westDoor2@p_rContents, o_door2W).
  446. AddEastChecker(r_westDoor2, door2Checker, false).
  447.  
  448. define tp_proving5 o_door1NW CreateThing(o_doorModel1).
  449. o_door1NW@p_oState := 0.
  450. o_door1NW@p_oSound := "Thud!".
  451. o_door1NW@p_oDoorName := "north-west".
  452. AddTail(r_northwestDoor@p_rContents, o_door1NW).
  453. AddNorthWestChecker(r_northwestDoor, door1Checker, false).
  454. define tp_proving5 o_door2NW CreateThing(o_doorModel2).
  455. o_door2NW@p_oOtherDoor := o_door1NW.
  456. AddTail(r_northwestDoor2@p_rContents, o_door2NW).
  457. AddSouthEastChecker(r_northwestDoor2, door2Checker, false).
  458.  
  459. define tp_proving5 o_door1N CreateThing(o_doorModel1).
  460. o_door1N@p_oState := 0.
  461. o_door1N@p_oSound := "Boom!".
  462. o_door1N@p_oDoorName := "north".
  463. AddTail(r_northDoor@p_rContents, o_door1N).
  464. AddNorthChecker(r_northDoor, door1Checker, false).
  465. define tp_proving5 o_door2N CreateThing(o_doorModel2).
  466. o_door2N@p_oOtherDoor := o_door1N.
  467. AddTail(r_northDoor2@p_rContents, o_door2N).
  468. AddSouthChecker(r_northDoor2, door2Checker, false).
  469.  
  470. define tp_proving5 o_door1NE CreateThing(o_doorModel1).
  471. o_door1NE@p_oState := 0.
  472. o_door1NE@p_oSound := "Crash!".
  473. o_door1NE@p_oDoorName := "north-east".
  474. AddTail(r_northeastDoor@p_rContents, o_door1NE).
  475. AddNorthEastChecker(r_northeastDoor, door1Checker, false).
  476. define tp_proving5 o_door2NE CreateThing(o_doorModel2).
  477. o_door2NE@p_oOtherDoor := o_door1NE.
  478. AddTail(r_northeastDoor2@p_rContents, o_door2NE).
  479. AddSouthWestChecker(r_northeastDoor2, door2Checker, false).
  480.  
  481. define tp_proving5 o_door1E CreateThing(o_doorModel1).
  482. o_door1E@p_oState := 0.
  483. o_door1E@p_oSound := "Bang!".
  484. o_door1E@p_oDoorName := "east".
  485. AddTail(r_eastDoor@p_rContents, o_door1E).
  486. AddEastChecker(r_eastDoor, door1Checker, false).
  487. define tp_proving5 o_door2E CreateThing(o_doorModel2).
  488. o_door2E@p_oOtherDoor := o_door1E.
  489. AddTail(r_eastDoor2@p_rContents, o_door2E).
  490. AddWestChecker(r_eastDoor2, door2Checker, false).
  491.  
  492. define tp_proving5 p_oDoors CreateThingListProp().
  493. define tp_proving5 p_oMapping CreateIntListProp().
  494. o_winch@p_oDoors := CreateThingList().
  495. AddTail(o_winch@p_oDoors, o_door1W).
  496. AddTail(o_winch@p_oDoors, o_door1NW).
  497. AddTail(o_winch@p_oDoors, o_door1N).
  498. AddTail(o_winch@p_oDoors, o_door1NE).
  499. AddTail(o_winch@p_oDoors, o_door1E).
  500. o_winch@p_oMapping := CreateIntArray(5).
  501.  
  502. define tp_proving5 proc doorsEntranceDesc()string:
  503.     string str, doorName;
  504.     int openCount, i, openOne;
  505.     list thing doors;
  506.  
  507.     doors := o_winch@p_oDoors;
  508.     openCount := 0;
  509.     for i from 0 upto 4 do
  510.     if doors[i]@p_oState = 1 then
  511.         openOne := i;
  512.         openCount := openCount + 1;
  513.     fi;
  514.     od;
  515.     if openCount = 0 then
  516.     str := "All of the doors are closed."
  517.     elif openCount = 1 then
  518.     str := "The " + doors[i]@p_oDoorName + " door is open.";
  519.     elif openCount = 2 then
  520.     str := "";
  521.     for i from 0 upto 4 do
  522.         if doors[i]@p_oState = 1 then
  523.         doorName := doors[i]@p_oDoorName;
  524.         if str = "" then
  525.             str := "The " + doorName + " and ";
  526.         else
  527.             str := str + doorName + " doors are open.";
  528.         fi;
  529.         fi;
  530.     od;
  531.     else
  532.     /* openCount = 3, other values should not be possible */
  533.     for i from 0 upto 4 do
  534.         if doors[i]@p_oState = 1 then
  535.         doorName := doors[i]@p_oDoorName;
  536.         case openCount
  537.         incase 3:
  538.             str := "The " + doorName + ", ";
  539.         incase 2:
  540.             str := str + doorName + " and ";
  541.         incase 1:
  542.             str := str + doorName + " doors are open.";
  543.         esac;
  544.         openCount := openCount - 1;
  545.         fi;
  546.     od;
  547.     fi;
  548.     "This small chamber has 5 doors in it, heading east, northeast, north, "
  549.     "northwest and west. Over each door is a carved eye, and a similar but "
  550.     "larger carving fills much of the floor. " + str + " There is also a "
  551.     "passage leading south, which you are currently in front of."
  552. corp;
  553. r_doorsEntrance@p_rDescAction := doorsEntranceDesc.
  554.  
  555. o_winch@p_oSoundList := CreateThingList().
  556. AddTail(o_winch@p_oSoundList, r_westDoor).
  557. AddTail(o_winch@p_oSoundList, r_northwestDoor).
  558. AddTail(o_winch@p_oSoundList, r_northDoor).
  559. AddTail(o_winch@p_oSoundList, r_northeastDoor).
  560. AddTail(o_winch@p_oSoundList, r_eastDoor).
  561. AddTail(o_winch@p_oSoundList, r_westDoor2).
  562. AddTail(o_winch@p_oSoundList, r_northwestDoor2).
  563. AddTail(o_winch@p_oSoundList, r_northDoor2).
  564. AddTail(o_winch@p_oSoundList, r_northeastDoor2).
  565. AddTail(o_winch@p_oSoundList, r_eastDoor2).
  566. AddTail(o_winch@p_oSoundList, r_doorsExit).
  567.  
  568. define tp_proving5 DOOR_TIME    8.
  569.  
  570. define tp_proving5 proc dropDoor(thing door; bool lightThere)void:
  571.     string sound, sound2;
  572.  
  573.     sound := door@p_oSound;
  574.     sound2 := sound + "\n";
  575.     SayToList(o_winch@p_oSoundList, sound2);
  576.     ABPrint(r_doorsEntrance, nil, nil,
  577.     if lightThere then
  578.         sound + " The " + door@p_oDoorName + " door slams closed!\n"
  579.     else
  580.         sound2
  581.     fi);
  582.     ABPrint(r_tunnelX7, nil, nil, sound2);
  583.     ABPrint(r_tunnelX6, nil, nil, sound2);
  584.     ABPrint(r_tunnelX5, nil, nil, "Rattle-rattle-clang! " + sound +
  585.     if o_winch@p_oState = 0 then
  586.         " The winch releases the rest of the way.\n"
  587.     else
  588.         " The winch releases part way.\n"
  589.     fi);
  590.     door@p_oState := 0;
  591. corp;
  592.  
  593. define tp_proving5 proc doorsDrop(thing winch)void:
  594.     int state;
  595.  
  596.     state := o_winch@p_oState;
  597.     if state ~= 0 then
  598.     state := state - 1;
  599.     o_winch@p_oState := state;
  600.     dropDoor(o_winch@p_oDoors[o_winch@p_oMapping[state]], false);
  601.     if state ~= 0 then
  602.         DoAfter(DOOR_TIME, winch, doorsDrop);
  603.     fi;
  604.     fi;
  605. corp;
  606.  
  607. define tp_proving5 proc clearWinch(bool lightThere)void:
  608.     int state;
  609.     list int li;
  610.     list thing lt;
  611.  
  612.     state := o_winch@p_oState;
  613.     li := o_winch@p_oMapping;
  614.     lt := o_winch@p_oDoors;
  615.     while state ~= 0 do
  616.     state := state - 1;
  617.     o_winch@p_oState := state;
  618.     dropDoor(lt[li[state]], lightThere);
  619.     od;
  620. corp;
  621.  
  622. define tp_proving5 proc doorsEnter()status:
  623.  
  624.     if o_winch@p_oState ~= 0 then
  625.     ignore CancelDoAfter(o_winch, doorsDrop);
  626.     doorsDrop(o_winch);
  627.     fi;
  628.     continue
  629. corp;
  630. AddAnyEnterChecker(r_tunnelX5, doorsEnter, false).
  631. AddAnyEnterChecker(r_tunnelX6, doorsEnter, false).
  632. AddAnyEnterChecker(r_tunnelX7, doorsEnter, false).
  633.  
  634. define tp_proving5 proc doorsLightEnter()status:
  635.  
  636.     if o_winch@p_oState ~= 0 then
  637.     ignore CancelDoAfter(o_winch, doorsDrop);
  638.     if HasLight(Me()) then
  639.         clearWinch(true);
  640.     else
  641.         doorsDrop(o_winch);
  642.     fi;
  643.     fi;
  644.     continue
  645. corp;
  646. AddAnyEnterChecker(r_doorsEntrance, doorsLightEnter, false).
  647. AddAnyEnterChecker(r_westDoor, doorsLightEnter, false).
  648. AddAnyEnterChecker(r_northwestDoor, doorsLightEnter, false).
  649. AddAnyEnterChecker(r_northDoor, doorsLightEnter, false).
  650. AddAnyEnterChecker(r_northeastDoor, doorsLightEnter, false).
  651. AddAnyEnterChecker(r_eastDoor, doorsLightEnter, false).
  652. AddAnyEnterChecker(r_doorsExit, doorsLightEnter, false).
  653. AddAnyEnterChecker(r_westDoor2, doorsLightEnter, false).
  654. AddAnyEnterChecker(r_northwestDoor2, doorsLightEnter, false).
  655. AddAnyEnterChecker(r_northDoor2, doorsLightEnter, false).
  656. AddAnyEnterChecker(r_northeastDoor2, doorsLightEnter, false).
  657. AddAnyEnterChecker(r_eastDoor2, doorsLightEnter, false).
  658.  
  659. define tp_proving5 proc turnWinch()status:
  660.     int i, j, temp;
  661.     list int li;
  662.     list thing lt;
  663.  
  664.     if o_winch@p_oState ~= 0 then
  665.     Print("Before you can crank up the winch, you first release it from "
  666.         "its current position. ");
  667.     ignore CancelDoAfter(o_winch, doorsDrop);
  668.     clearWinch(false);
  669.     fi;
  670.     Print("The winch turns easily and you quickly crank it up all the way.\n");
  671.     if CanSee(r_tunnelX5, Me()) then
  672.     OPrint(Me()@p_pName + " cranks the winch up.\n");
  673.     else
  674.     OPrint("You hear someone cranking the winch.\n");
  675.     fi;
  676.     li := o_winch@p_oMapping;
  677.     lt := o_winch@p_oDoors;
  678.     for i from 0 upto 4 do
  679.     li[i] := i;
  680.     lt[i]@p_oState := 1;
  681.     od;
  682.     for i from 0 upto 4 do
  683.     j := Random(5 - i);
  684.     temp := li[i + j];
  685.     li[i + j] := li[i];
  686.     li[i] := temp;
  687.     od;
  688.     o_winch@p_oState := 5;
  689.     if LightAt(r_doorsEntrance) or LightAt(r_westDoor) or
  690.     LightAt(r_northwestDoor) or LightAt(r_northDoor) or
  691.     LightAt(r_northeastDoor) or LightAt(r_eastDoor) or
  692.     LightAt(r_doorsExit) or LightAt(r_westDoor2) or
  693.     LightAt(r_northwestDoor2) or LightAt(r_northDoor2) or
  694.     LightAt(r_northeastDoor2) or LightAt(r_eastDoor2)
  695.     then
  696.     SayToList(o_winch@p_oSoundList, "The door smoothly rises up.\n");
  697.     ABPrint(r_doorsEntrance, nil, nil,"The doors all smoothly rise up.\n");
  698.     clearWinch(true);
  699.     else
  700.     DoAfter(DOOR_TIME, o_winch, doorsDrop);
  701.     fi;
  702.     succeed
  703. corp;
  704. o_winch@p_oTurnChecker := turnWinch.
  705.  
  706. unuse tp_proving5
  707.